﻿Imports System.Windows.Forms
Imports CapaNegocio
Imports capaPresentacion.mdlVariables
Imports System.Net

Public Class frmInicio
    'Dim intento As Integer = 0
    Private Sub frmInicio_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Application.Exit()
    End Sub

    Private Sub frmInicio_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

    End Sub

    Private Sub frmInicio_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtUsuario.Focus()
    End Sub

    Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click
        'Salir con boton
        'Dim msgSalir
        'msgSalir = MsgBox("¿Realmente desea salir?", MsgBoxStyle.YesNo Or MsgBoxStyle.Exclamation)
        'If msgSalir = MsgBoxResult.Yes Then
        Me.Close()
        'End If
    End Sub

    Private Sub activarconexiones()
        'cU.cadena = cadenacon
        ''cP.cadena = cadenacon
        'cE.cadena = cadenacon
        'cB.cadena = cadenacon
    End Sub

    Private Sub lblIntentos_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblIntentos.DoubleClick
        Dim b As Boolean = True
        Dim frmcon As New frmConexion

        While b
            If InputBox(AcceptButton, "Contraseña") = "ilab" Then
                b = False
                frmcon.Show()
            End If
        End While
    End Sub

    Private Sub btnIngresar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIngresar.Click
        cU.usuarioUsuario = LCase(txtUsuario.Text)
        cU.contraseniaUsuario = txtContraseña.Text
        cU.ipAuditoria = ip
        cU.pcAuditoria = pc
        cU.usuariopcAuditoria = usuariopc

        'cC.cadenaconexionx = cadenacon
        'MsgBox(cadenacon)
        'cC.cadenaconexionx = cadenacon
        'MsgBox(cC.cadenaconexionx)

        'activarconexiones()

        If (cU.mtdIniciarSesion()) Then
            'MsgBox("Bienvenido al Sistema iLab.")
            Me.Hide()
            'Sistema
            Dim sistema As New frmSistema
            sistema.Show()
        Else
            txtUsuario.ResetText()
            txtContraseña.ResetText()
            txtUsuario.Focus()
            'intento = intento + 1
            'If intento < maxIntentos Then
            'lblIntentos.Text = "Le quedan " + (maxIntentos - intento) + " más."
            'End If
        End If
    End Sub

    Private Sub txtContraseña_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtContraseña.KeyPress
        'Tabulacion
        If e.KeyChar = ChrW(Keys.Enter) Then
            e.Handled = True
            SendKeys.Send("{TAB}")
        ElseIf Char.IsSeparator(e.KeyChar) Then 'Validacion -> SIN espacio
            e.Handled = True
        ElseIf Char.IsDigit(e.KeyChar) Then 'Validacion -> Ingreso de datos SOLO NUMEROS
            e.Handled = False
        ElseIf Char.IsLetter(e.KeyChar) Then 'Validacion -> Ingreso de datos SOLO LETRAS
            e.Handled = False
        ElseIf Char.IsControl(e.KeyChar) Then 'Validacion -> CON delete
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub

    Private Sub txtUsuario_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtUsuario.KeyPress
        'Tabulacion
        If e.KeyChar = ChrW(Keys.Enter) Then
            e.Handled = True
            SendKeys.Send("{TAB}")
        ElseIf Char.IsSeparator(e.KeyChar) Then 'Validacion -> SIN espacio
            e.Handled = True
        ElseIf Char.IsLetter(e.KeyChar) Then 'Validacion -> Ingreso de datos SOLO LETRAS
            e.Handled = False
        ElseIf Char.IsControl(e.KeyChar) Then 'Validacion -> CON delete
            e.Handled = False
        Else
            e.Handled = True
        End If
    End Sub
End Class